home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / mutt / me2s_pl7.zoo / mu_edit2 / ed / xpandkey.c < prev   
Encoding:
C/C++ Source or Header  |  1993-07-05  |  1.5 KB  |  57 lines

  1. static char rcsid[] = "$Id: xpandkey.c,v 1.2 1992/12/28 00:53:30 mike Exp $";
  2.  
  3. /* $Log: xpandkey.c,v $
  4.  * Revision 1.2  1992/12/28  00:53:30  mike
  5.  * - `ktoa' recognizes the `A-' prefix now.
  6.  *
  7.  * Revision 1.1  1992/09/14  13:02:14  mike
  8.  * Initial revision
  9.  *
  10.  */
  11.  
  12. /* xpandkey.c : 
  13.  * C Durland
  14.  */
  15.  
  16. /* Copyright 1990, 1991 Craig Durland
  17.  *   Distributed under the terms of the GNU General Public License.
  18.  *   Distributed "as is", without warranties of any kind, but comments,
  19.  *     suggestions and bug reports are welcome.
  20.  */
  21.  
  22. #include "ed.h"
  23.  
  24. extern KeyCode Eprefixes[];
  25. static void ktoa();
  26.  
  27.    /* Convert a KeyCode to a something that is printable.
  28.     * Example output:  a, A, C-A, M-A, S-F-A, C-XC-C, etc.
  29.     * Warning:  Make sure buf is NULL terminated BEFORE you call this!
  30.     *   (because strcat() is used).
  31.     */
  32. void Expand_key(pkeys,keycode,buf) PKey *pkeys; KeyCode keycode; char *buf;
  33. {
  34.   register int j;
  35.  
  36.     /* check for PFIX1, 2 or 3.  META handled automatically. */
  37.   for (j = 1; j<PKEYS; j++) if (Eprefixes[j] & keycode) ktoa(buf,pkeys[j]);
  38.   ktoa(buf,keycode);
  39. }
  40.  
  41. static void ktoa(buf,keycode) char *buf; KeyCode keycode;
  42. {
  43.   char foo[2];
  44.  
  45.   foo[1] = '\0';
  46.   if (keycode & META)   strcat(buf,"M-");
  47. #ifdef atarist
  48.   if (keycode & PFIX2)  strcat(buf,"A-");
  49. #endif
  50.   if (keycode & SHIFT)  strcat(buf,"S-");
  51.   if (keycode & CTRL)   strcat(buf,"C-");
  52.   if (keycode & SOFKEY) strcat(buf,"F-");
  53.   
  54.   *foo = keycode & 0xFF;    /* get rid of modifier bits */
  55.   strcat(buf,foo);
  56. }  
  57.